package com.example.myapplication1111.ui.place

import androidx.lifecycle.*
import com.example.sjh_web.weather.sjh_Repository
import com.example.sjh_web.weather.model.Place

class sjh_PlaceViewModel : ViewModel() {

    private val searchLiveData = MutableLiveData<String>()

    val placeList = ArrayList<Place>()

    val placeLiveData = Transformations.switchMap(searchLiveData) { query ->
        sjh_Repository.searchPlaces(query)
    }

    fun searchPlaces(query: String) {
        searchLiveData.value = query
    }

    fun savePlace(place: Place) = sjh_Repository.savePlace(place)

    fun getSavedPlace() = sjh_Repository.getSavedPlace()

    fun isPlaceSaved() = sjh_Repository.isPlaceSaved()

}